package cate.game.play.skill.passive.god;

import cate.game.play.base.TargetFilterParam;
import cate.game.play.base.TargetSelector;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 友方目标数大于2且自身为前排时回合开始50%概率对敌方1个单位附加【挑衅】1回合，附带【挑衅】时攻击会优先攻击你且只造成75%的伤害
 */
public class 干扰PH extends PassiveHandler {

	private int 人数;
	private int 概率;
	private int buff;

	//人数=2&概率=5000&buff=？？
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		人数 = args.getInt("人数", 0);
		概率 = args.getInt("概率", 0);
		buff = args.getInt("buff", 0);
	}

	@Override
	public void onRoundBegin(ActionCtx action) {
		if (skill.owner.isDead()) {
			return;
		}
		if (skill.owner.getPos() > 3) {
			return;
		}
		if (skill.owner.getFightTeam().getFightersAlive().size() < 人数 + 1) {
			return;
		}
		Fighter target = TargetSelector.findOne(skill.owner, action.getTeamVs(), new TargetFilterParam());
		if (target == null) {
			return;
		}
		target.buff.tryAddByTid(action, skill.owner, buff, 概率);
	}
}
